---
title: clsTaskCollection
summary: API reference for clsTaskCollection.
status: draft
owner: SAIF Documentation
last_reviewed: 2026-08-21
library: SAIF.Business.Tasks
reference_type: embedded
---

# clsTaskCollection

`clsTaskCollection` is the abstract collection type for tasks, providing the dynamic, criteria-driven search subsystem (`GetTasks`), collection-level save (`Save`), and batch purge (`PurgeTasks`). Its nested `Criteria` class is a self-contained SQL-assembly component that builds a filtered `TASK` query from up to ten optional predicates.

## Purpose
- Retrieve a filtered list of tasks matching caller-supplied criteria, materializing each row into a concrete task instance via the abstract `NewTask()` factory (see [Retrieve a filtered task list](../../operations/retrieve-filtered-task-list.md)).
- Batch-persist pending edits across a collection by delegating to the framework's per-item save lifecycle (see [Save a task collection](../../operations/save-task-collection.md)).
- Purge previously completed tasks older than a retention window via `PK82036_Task.Task_Purge` (see [Purge completed tasks](../../operations/purge-completed-tasks.md)).

## Context
- Namespace: `SAIF.Business.Tasks`
- Assembly/package: `SAIF.Business.Tasks` (embedded in the `LegalMaintenance` web deployment)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `Item` | `Default ReadOnly Property Item(Index As Integer) As iTask` | Positional access to a task within the collection. |
| `Item` | `Default ReadOnly Property Item(inTaskSeqNum As String) As iTask` | Access a task within the collection by its sequence number. |
| `GetTasks` | `Shared Function GetTasks(inDataPortalInfo As IDataPortalInfo, inSelectionCriteria As Criteria) As clsTaskCollection` | Factory/retrieval entry point; assembles and executes the dynamic filtered `TASK` query ([SQL-008](../../sql/SQL-008-retrieve-filtered-task-list.md)). |
| `PurgeTasks` | `Shared Function PurgeTasks(inDataPortalInfo As IDataPortalInfo, inTaskSourceCode As String, inTaskCategoryCode As String, inKeepDays As Integer) As Integer` | Batch-deletes completed tasks older than the retention window via `PK82036_Task.Task_Purge` ([SQL-015](../../sql/SQL-015-purge-tasks.md)); returns the count of purged rows. |
| `NewTask` | `MustOverride Function NewTask() As iTask` | Abstract — descendant factory hook that materializes a concrete task instance for a retrieved row. |
| `Save` | `Overrides Function Save() As <result type>` | Applies pending edits (`ApplyEdit()`) then delegates to the framework base `Save()` for per-item persistence (see [Save a task collection](../../operations/save-task-collection.md)). |
| `Add` | `Sub Add(inTask As iTask)` | Adds a task to the collection. |
| `Remove` | `Sub Remove(inTask As iTask)` / `Sub Remove(inTaskSeqNum As Decimal)` | Removes a task by reference or by sequence number. |
| `Contains` | `Function Contains(...) As Boolean` | Checks whether the collection holds a given task (overloaded). |
| `ContainsDeleted` | `Function ContainsDeleted(...) As Boolean` | Checks whether a deleted/removed task is tracked (overloaded). |
| `MyCriteria` | `ReadOnly Property MyCriteria As Criteria` | The nested `Criteria` instance used for the last/pending retrieval. |
| `Criteria` | `Public Class Criteria` (nested, implements `IBusinessCriteria`) | Search-criteria builder; assembles the dynamic `TASK` `SELECT`/`WHERE` and binds parameters ([SQL-008](../../sql/SQL-008-retrieve-filtered-task-list.md)). |
| `Criteria.TaskCategoryCode`, `Criteria.TaskActionCode`, `Criteria.TaskPriority`, `Criteria.PriorityLevel` | `Property ... As String / TaskPriority` | Single-value category/action/priority filters ([BR-018](../../business-rules.md#br-018-a-priority-level-filter-selects-that-priority-and-all-higher-ones)). |
| `Criteria.BeginDate`, `Criteria.EndDate` | `Property ... As Date` | Date-range bounds compared against `trunc(TASK_DATE)` ([BR-020](../../business-rules.md#br-020-date-range-filtering-compares-the-truncated-task-date)). |
| `Criteria.MailID` | `Property MailID As String` | Assigned-user filter; normalized to upper-case ([BR-016](../../business-rules.md#br-016-mailids-are-stored-and-compared-trimmed-and-upper-cased)). |
| `Criteria.ShowCompleted` | `Property ShowCompleted As Boolean` | When false (default), excludes completed tasks ([BR-017](../../business-rules.md#br-017-completed-tasks-are-excluded-from-searches-unless-showcompleted-is-set)). |
| `Criteria.TaskText` | `Property TaskText As String` | Free-text search term concatenated unbound into a `LIKE` predicate*. |
| `Criteria.InnerSort`, `Criteria.OuterSort` | `Property ... As String` | Sort expressions used when row-limiting ([BR-021](../../business-rules.md#br-021-result-sets-may-be-capped-to-n-most-relevant-rows)). |
| `Criteria.RowNumLimit` | `Property RowNumLimit As Integer` | Caps the result set to N rows via an Oracle `rownum` wrapper ([BR-021](../../business-rules.md#br-021-result-sets-may-be-capped-to-n-most-relevant-rows)). |
| `Criteria.ContextCategory`, `Criteria.ContextCode`, `Criteria.ContextDate`, `Criteria.ContextKey`, `Criteria.ContextNumericValue`, `Criteria.ContextTextValue` | `Property ... As <smart type>` | Context-column filters; concatenated unbound into the SQL text*. |
| `Criteria.WhereClause` | `ReadOnly Property WhereClause As String` | Returns `m_LastSQLStatement`, which is never assigned — always an empty string (likely dead/legacy code)*. |
| `Criteria.ClaimList`, `Criteria.PolicyList`, `Criteria.TaskCategoryList`, `Criteria.TaskSourceList`, `Criteria.TaskActionCodeList` | `ReadOnly Property ... As <list>` | Accessors for the multi-value filter lists used to build `IN (...)` predicates ([BR-019](../../business-rules.md#br-019-filter-values-accept-single-values-or-lists)). |
| `Criteria.AddClaimID`, `Criteria.AddPolicyNumber`, `Criteria.AddTaskActionCode`, `Criteria.AddTaskCategory`, `Criteria.AddTaskSourceSystem` | `Sub Add*(...)` | Mutators that add a filter value, rejecting blank/zero entries ([BR-019](../../business-rules.md#br-019-filter-values-accept-single-values-or-lists)). |
| `Criteria.TaskSource` | `Property TaskSource(String) / TaskSource(TaskSourceSystem)` | Convenience overloads for setting the single-value source filter. |
| `Criteria.ClearCriteria` | `Sub ClearCriteria()` | Resets all filter state on the criteria object. |

## Behavioral notes
- The class is `<Serializable()>`, consistent with remoting/session persistence of BOF objects across the web tier*.
- `Criteria.FormatRequest` applies predicates in a fixed order (other-parameters → source → category → priority → date → MailID → claim → policy → action → context), then optionally wraps with `rownum` limiting.

## Constraints and usage notes
- `clsTaskCollection` is `MustInherit` — concrete collection types live in `SAIF.Business.Tasks.Claim`.
- `Criteria.TaskText` and all `Criteria.Context*` filters bypass bind-parameter binding, creating a SQL-injection risk that should be remediated independently of any Oracle-side changes*.

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Related documentation
- [API index](../index.md)
- [Operations and processes](../../operations-processes.md)
- [Business rules](../../business-rules.md)
- [Database tables](../../database-tables.md)

## Sources
- SAIF.Business.Tasks/clsTaskCollection.vb
